package com.human.server.controller;

import com.human.server.entity.Templates;
import com.human.server.model.R;
import com.human.server.model.request.TemplatesRequest;
import com.human.server.service.impl.TemplatesServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/human/templates")
public class TemplatesController {

    @Autowired
    private TemplatesServiceImpl templatesService;

    @RequestMapping("/list")
    public R list() {
        return R.success(templatesService.list());
    }

    /**
     * 新增
     */
    @RequestMapping("/add")
    public R add(@RequestBody Templates templates) {
        return R.success(templatesService.save(templates));
    }

    /**
     * 更新
     */
    @RequestMapping("/update")
    public R update(@RequestBody Templates templates) {
        return R.success(templatesService.updateById(templates));
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Templates templates) {
        return R.success(templatesService.removeById(templates));
    }

    /**
     * 详情
     */
    @RequestMapping("/query")
    public R query(@RequestBody Templates templates) {
        return R.success(templatesService.getById(templates.getId()));
    }

    /**
     * 分页
     */
    @RequestMapping("/page")
    public R page(@RequestBody TemplatesRequest templatesRequest) {

        return R.success(templatesService.page(templatesRequest));
    }
}
